  IDE_TYPICAL_TIMEOUT                 EQU       0x00001000
  ; General IDE ports
  IDEC_PORT_ALTERNATESTATUS           EQU       0X000003F8 ; Read
  IDEC_PORT_DEVICECONTROL             EQU       0X000003F8 ; Write
  IDEC_PORT_DRIVEADDRESS              EQU       0X000003F9 ; Read

  IDE_PORT_OFFSET_DATA                EQU       0x00000000
  IDE_PORT_OFFSET_ERROR               EQU       0x00000001
  IDE_PORT_OFFSET_FEATURES            EQU       0x00000001
  IDE_PORT_OFFSET_SECTORCOUNT         EQU       0x00000002
  IDE_PORT_OFFSET_SECTORNUMBER        EQU       0x00000003
  IDE_PORT_OFFSET_LBABITS0TO7         EQU       0x00000003
  IDE_PORT_OFFSET_CYLINDERLOW         EQU       0x00000004
  IDE_PORT_OFFSET_LBABITS8TO15        EQU       0x00000004
  IDE_PORT_OFFSET_CYLINDERHIGH        EQU       0x00000005
  IDE_PORT_OFFSET_LBABITS16TO23       EQU       0x00000005
  IDE_PORT_OFFSET_DRIVEHEAD           EQU       0x00000006
  IDE_PORT_OFFSET_LBABITS24TO27       EQU       0x00000006
  IDE_PORT_OFFSET_STATUS              EQU       0x00000007
  IDE_PORT_OFFSET_COMMAND             EQU       0x00000007

  ; PIDEC_PORT = Primary IDE Controller Port
  PIDEC_PORT_BASE                     EQU       0x000001F0 ; The base port for PIDEC (Primary IDE Controller)
  PIDEC_PORT_DATA                     EQU       0x000001F0 ; Read/Write
  PIDEC_PORT_ERROR                    EQU       0x000001F1 ; Read
  PIDEC_PORT_FEATURES                 EQU       0x000001F1 ; Write
  PIDEC_PORT_SECTORCOUNT              EQU       0x000001F2 ; Read/Write
  PIDEC_PORT_SECTORNUMBER             EQU       0x000001F3 ; Read/Write
  PIDEC_PORT_LBABITS0TO7              EQU       0x000001F3 ; Read/Write
  PIDEC_PORT_CYLINDERLOW              EQU       0x000001F4 ; Read/Write
  PIDEC_PORT_LBABITS8TO15             EQU       0x000001F4 ; Read/Write
  PIDEC_PORT_CYLINDERHIGH             EQU       0x000001F5 ; Read/Write
  PIDEC_PORT_LBABITS16TO23            EQU       0x000001F5 ; Read/Write
  PIDEC_PORT_DRIVEHEAD                EQU       0x000001F6 ; Read/Write
  PIDEC_PORT_LBABITS24TO27            EQU       0x000001F6 ; Read/Write
  PIDEC_PORT_STATUS                   EQU       0x000001F7 ; Read
  PIDEC_PORT_COMMAND                  EQU       0x000001F7 ; Write

  ; SIDEC_PORT = Secondary IDE Controller Port
  SIDEC_PORT_BASE                     EQU       0x00000170 ; The base port for SIDEC (Secodnary IDE Controller)
  SIDEC_PORT_DATA                     EQU       0x00000170 ; Read/Write
  SIDEC_PORT_ERROR                    EQU       0x00000171 ; Read
  SIDEC_PORT_FEATURES                 EQU       0x00000171 ; Write
  SIDEC_PORT_SECTORCOUNT              EQU       0x00000172 ; Read/Write
  SIDEC_PORT_SECTORNUMBER             EQU       0x00000173 ; Read/Write
  SIDEC_PORT_LBABITS0TO7              EQU       0x00000173 ; Read/Write
  SIDEC_PORT_CYLINDERLOW              EQU       0x00000174 ; Read/Write
  SIDEC_PORT_LBABITS8TO15             EQU       0x00000174 ; Read/Write
  SIDEC_PORT_CYLINDERHIGH             EQU       0x00000175 ; Read/Write
  SIDEC_PORT_LBABITS16TO23            EQU       0x00000175 ; Read/Write
  SIDEC_PORT_DRIVEHEAD                EQU       0x00000176 ; Read/Write
  SIDEC_PORT_LBABITS24TO27            EQU       0x00000176 ; Read/Write
  SIDEC_PORT_STATUS                   EQU       0x00000177 ; Read
  SIDEC_PORT_COMMAND                  EQU       0x00000177 ; Write

  ; Attached to the end of some of the commands are ...
  ;   ... W = With
  ;   ... WO = Without
  ; MIDE_CMD = Mandatory IDE Command
  MIDE_CMD_EXECUTEDRIVEDIAGNOSTIC     EQU       0x00000090
  MIDE_CMD_FORMATTRACK                EQU       0x00000050
  MIDE_CMD_INITIALIZEDRIVEPARAMS      EQU       0x00000091
  MIDE_CMD_READLONGWR                 EQU       0x00000022
  MIDE_CMD_READLONGWOR                EQU       0x00000023
  MIDE_CMD_READSECTORSWR              EQU       0x00000020
  MIDE_CMD_READSECTORSWOR             EQU       0x00000021
  MIDE_CMD_READVERIFYSECTORSWR        EQU       0x00000040
  MIDE_CMD_READVERIFYSECTORSWOR       EQU       0x00000041
  MIDE_CMD_RECALIBRATE                EQU       0x00000010
  MIDE_CMD_SEEK                       EQU       0x00000070
  MIDE_CMD_WRITELONGWR                EQU       0x00000032
  MIDE_CMD_WRITELONGWOR               EQU       0x00000033
  MIDE_CMD_WRITESECTORSWR             EQU       0x00000030
  MIDE_CMD_WRITESECTORSWOR            EQU       0x00000031

  ; OIDE_CMD = Optional IDE Command
  OIDE_CMD_ACKNOWLEDGEMEDIACHANGE     EQU       0x000000DB
  OIDE_CMD_BOOTPOSTBOOT               EQU       0x000000DC
  OIDE_CMD_BOOTPREBOOT                EQU       0x000000DD
  OIDE_CMD_CHECKPOWERMODE             EQU       0x000000E5
  OIDE_CMD_DOORLOCK                   EQU       0x000000DE
  OIDE_CMD_DOORUNLOCK                 EQU       0x000000DF
  OIDE_CMD_IDENTIFYDRIVE              EQU       0x000000EC
  OIDE_CMD_IDENTIFYDEVICE             EQU       0x000000EC
  OIDE_CMD_IDLE                       EQU       0x000000E3
  OIDE_CMD_IDLEIMMEDIATE              EQU       0x000000E1
  OIDE_CMD_NOP                        EQU       0x00000000
  OIDE_CMD_READBUFFER                 EQU       0x000000E4
  OIDE_CMD_READDMAWR                  EQU       0x000000C8
  OIDE_CMD_READDMAWOR                 EQU       0x000000C9
  OIDE_CMD_READMULTIPLE               EQU       0x000000C4
  OIDE_CMD_SETFEATURES                EQU       0x000000EF
  OIDE_CMD_SETMULTIPLEMODE            EQU       0x000000C6
  OIDE_CMD_SLEEP                      EQU       0x000000E6
  OIDE_CMD_STANDBY                    EQU       0x000000E2
  OIDE_CMD_STANDBYIMMEDIATE           EQU       0x000000E0
  OIDE_CMD_WRITEBUFFER                EQU       0x000000C8
  OIDE_CMD_WRITEDMAWR                 EQU       0x000000CA
  OIDE_CMD_WRITEDMAWOR                EQU       0x000000CB
  OIDE_CMD_WRITEMULTIPLE              EQU       0x000000C5
  OIDE_CMD_WRITESAME                  EQU       0x000000E9
  OIDE_CMD_WRITEVERIFY                EQU       0x0000003C

  ; IDE, Drive/Head Register bitmask
  IDE_DRIVEHEADREG_HS0                EQU       0x00000001
  IDE_DRIVEHEADREG_HS1                EQU       0x00000002
  IDE_DRIVEHEADREG_HS2                EQU       0x00000004
  IDE_DRIVEHEADREG_HS3                EQU       0x00000008
  IDE_DRIVEHEADREG_DRV                EQU       0x00000010
  IDE_DRIVEHEADREG_L                  EQU       0x00000040  ; If set, operation = LBA. If cleared, operaton = CHS
  IDE_DRIVEHEADREG_DEFAULTVALUE       EQU       0x000000A0
  IDE_DRIVEHEADREG_PRIMARYDRIVE       EQU       0x00000000
  IDE_DRIVEHEADREG_SECONDARYDRIVE     EQU       IDE_DRIVEHEADREG_DRV
  IDE_DRIVEHEADREG_PRIMARYBITMASK     EQU       IDE_DRIVEHEADREG_DEFAULTVALUE | IDE_DRIVEHEADREG_PRIMARYDRIVE
  IDE_DRIVEHEADREG_SECONDARYBITMASK   EQU       IDE_DRIVEHEADREG_DEFAULTVALUE | IDE_DRIVEHEADREG_SECONDARYDRIVE

  ; IDE, Status Register bitmask
  IDE_STATUSREG_ERR                   EQU       0x00000001
  IDE_STATUSREG_IDX                   EQU       0x00000002
  IDE_STATUSREG_CORR                  EQU       0x00000004
  IDE_STATUSREG_DRQ                   EQU       0x00000008
  IDE_STATUSREG_DSC                   EQU       0x00000010
  IDE_STATUSREG_DWF                   EQU       0x00000020
  IDE_STATUSREG_DRDY                  EQU       0x00000040
  IDE_STATUSREG_BSY                   EQU       0x00000080

  IDE_FEATURESREG_ENABLE8BITTRANS     EQU       0x00000001
  IDE_FEATURESREG_ENABLEWRITECACHE    EQU       0x00000002
  IDE_FEATURESREG_SETTRANSFERMODE     EQU       0x00000003
  IDE_FEATURESREG_DISABLERETRY        EQU       0x00000033
  IDE_FEATURESREG_ECCLENGTH           EQU       0x00000044
  IDE_FEATURESREG_SETCACHESEGMENTS    EQU       0x00000054
  IDE_FEATURESREG_DISABLELOOKAHEAD    EQU       0x00000055
  IDE_FEATURESREG_DISABLERESET        EQU       0x00000066
  IDE_FEATURESREG_DISABLEECC          EQU       0x00000077
  IDE_FEATURESREG_DISABLE8BITTRANS    EQU       0x00000081
  IDE_FEATURESREG_ENABLEECC           EQU       0x00000088
  IDE_FEATURESREG_DISABLEWRITECHACHE  EQU       0x00000082
  IDE_FEATURESREG_ENABLERETRIES       EQU       0x00000099
  IDE_FEATURESREG_ENABLELOOKAHEAD     EQU       0x000000AA
  IDE_FEATURESREG_SETMAXPREFETCH      EQU       0x000000AB
  IDE_FEATURESREG_ENABLERESET         EQU       0x000000CC

  ; IDE, Error Register Bitmask
  IDE_ERRORREG_AMNF                   EQU       0x00000001
  IDE_ERRORREG_TK0NF                  EQU       0x00000002
  IDE_ERRORREG_ABRT                   EQU       0x00000004
  IDE_ERRORREG_MCR                    EQU       0x00000008
  IDE_ERRORREG_IDNF                   EQU       0x00000010
  IDE_ERRORREG_MC                     EQU       0x00000020
  IDE_ERRORREG_UNC                    EQU       0x00000040
  IDE_ERRORREG_BBK                    EQU       0x00000080

  ; IDE, Alternate Status Register Bitmask
  IDE_ALTERNATESTATUSREG_ERR          EQU       0x00000001
  IDE_ALTERNATESTATUSREG_IDX          EQU       0x00000002
  IDE_ALTERNATESTATUSREG_CORR         EQU       0x00000004
  IDE_ALTERNATESTATUSREG_DRQ          EQU       0x00000008
  IDE_ALTERNATESTATUSREG_DSC          EQU       0x00000010
  IDE_ALTERNATESTATUSREG_DWF          EQU       0x00000020
  IDE_ALTERNATESTATUSREG_DRDY         EQU       0x00000040
  IDE_ALTERNATESTATUSREG_BSY          EQU       0x00000080

  ; IDE, Device Control Register Bitmask
  IDE_DEVICECONTROLREG_DEFAULTVALUE   EQU       0x00000008
  IDE_DEVICECONTROLREG_nIEN           EQU       0x00000002
  IDE_DEVICECONTROLREG_SRST           EQU       0x00000004

  IDE_PRIMARY_CONTROLLER              EQU       0x00000000
  IDE_SECONDARY_CONTROLLER            EQU       0x00000001
  IDE_DRIVE0                          EQU       0x00000000
  IDE_DRIVE1                          EQU       0x00000001

